package com.atguigu.lease.common.handle;

import com.atguigu.lease.common.exception.MyBusinessException;
import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName MyExceptionHandle
 * @Author heartFade
 * @Date 2025-04-26 21:07
 * @Version 1.0
 * @Description TODO
 **/
@RestControllerAdvice
public class MyExceptionHandle {
    @ExceptionHandler(MyBusinessException.class)
    public Result handleBusinessException(MyBusinessException e)
    {
        return Result.fail(e.getCode(),e.getMessage());
    }
//    @ExceptionHandler(Exception.class)
//   public Result handleException(Exception e)
//    {
//        System.out.println(e.getMessage()+" "+e.getCause());
//        return Result.fail(200000,"未知错误");
//    }
}
